package com.amado.rmi;

import com.amado.rmi.sevice.RuleService;

import java.net.MalformedURLException;
import java.rmi.Naming;
import java.rmi.NotBoundException;
import java.rmi.RemoteException;

/**
 * Created by Administrator on 2018/12/12.
 */
public class MainClient {
    public static void main(String []args) {
        try {
            //在RMI服务注册表中查找名称为RHello的对象，并调用其上的方法
            RuleService ruleService = (RuleService) Naming.lookup("rmi://localhost:8888/ruleService");
            System.out.println("返回结果:"+ruleService.getRule("DIAG_1001"));
            System.out.println("返回结果:"+ruleService.list());
        } catch (NotBoundException e) {
            e.printStackTrace();
        } catch (MalformedURLException e) {
            e.printStackTrace();
        } catch (RemoteException e) {
            e.printStackTrace();
        }
    }
}
